<template>
	<view class="policy_box">
		<view class="policy_list" v-if="data !== undefined && data!== null && data.length>0">
			<view class="policy_title_tag">
				<text class="policy_title">余额</text>
				<text style="color: #fff;">{{total}}</text>
			</view>
			<view class="ha_setup_box" v-for="(item,index) in data" :key="index">
				<view class="policy_list ha_box">
					<view class="ha_setup_list">
						<text class="profit_tag" v-if="item.type == 'base'">基础</text>
						<text class="profit_tag" v-if="item.type == 'hide'">隐形</text>
						<view class="info_item">
							<text>{{item.total}}</text>
						</view>
						<view class="operating">
							<view class="fize" style="background-color: #8292d3;"
								@click="details(item.balance_type_id,item.type)">详情</view>
							<view class="fize" style="background-color: #73d8db;"
								@click="cash(item.type,item.balance_type_id,item.total)">提现</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<u-empty v-else mode="list" icon="/static/Empty/data_null.png">
		</u-empty>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: [],
				total: null,
				type_id: null,
				name: null
			}
		},
		onLoad(e) {
			this.type_id = e.balance_type_id
			this.total = e.total
			this.name = e.name
			uni.setNavigationBarTitle({
				title: e.name
			})
		},
		onShow() {
			this._request()
		},
		methods: {
			// 提现
			cash(type, balance_type_id, total) {
				uni.navigateTo({
					url: '/pages/mine/profit/Cash/Cash?type=' + type + '&balance_type_id=' + balance_type_id +
						'&total=' + total
				})
			},
			details(type_id, type) {
				uni.navigateTo({
					url: '/pages/mine/profit/profit_details?type_id=' + type_id + '&type=' + type + '&name=' + this.name
				})
			},
			async _request() {
				const userinfo = uni.getStorageSync('userinfo');
				const {
					data: res
				} = await this.$myHttp({
					url: 'balance/getTypePart',
					data: {
						balance_type_id: this.type_id
					},
					header: {
						'token': userinfo.token
					},
				});
				if (res.code == 1) {
					this.data = res.data
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'none',
						duration: 3000
					})
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.policy_box {
		padding: 30rpx;
		box-sizing: border-box;
	}

	.policy_title_tag {
		display: block;
		padding:40rpx ;
		margin-bottom: 54rpx;
		background:linear-gradient(to right, #4a67f8, #736cf9);
		display: flex;
		justify-content: space-between;
		border-radius: 15rpx;
		
		text {
			font-weight: bold;
		}

		.policy_title {
			padding: 0 0 4rpx 10rpx;
			display: block;
			font-size: 32rpx;
			color: #fff;
			font-weight: bold;
		}
	}

	.ha_box {
		box-shadow: 0px 1px 14px -10px #999;
		background:url(/static/car1_bg.png) no-repeat right top,linear-gradient(to right, #e1eaff, #dde6fe);
		background-size: auto 100%;
		
	}

	.policy_list {
		padding: 20rpx;
		border-radius: 15rpx;
		// box-shadow: 0px 1px 14px -10px #999;
		margin-bottom: 30rpx;

		.ha_setup_list {
			margin-bottom: 20rpx;
		}

		.info_item {
			display: flex;
			justify-content: center;
			font-size: 34rpx;
			
			text {
				font-weight: bold;
				font-size: 44rpx;
				color: #12045c;
			}
		}

		.operating {
			display: flex;
			justify-content: space-between;

			.fize {
				color: #fff;
				padding: 10rpx 30rpx;
				border-radius: 30rpx;
				margin-top: 30rpx;
				font-size: 24rpx;
			}
		}

	}
</style>